package acwing._2LanQiao._2BinarySearch_PrefixSum;

import java.util.Scanner;

/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._2BinarySearch_PrefixSum
 * @File : Q0789.java
 * @Author : WangRuoyu
 * @Date : 2023/3/13 15:49
 */

public class Q0789 {

    static void find(int[] q, int k) {
        int l = 0;
        int r = q.length - 1;

        while (l < r) {
            int mid = (l + r) / 2;
            if (q[mid] >= k) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        if (q[l] != k) {
            System.out.println(-1 + " " + -1);
            return;
        }

        int i = l;
        r = q.length - 1;

        while (l < r) {
            int mid = (l + r + 1) / 2;
            if (q[mid] <= k) {
                l = mid;
            } else {
                r = mid - 1;
            }
        }
        System.out.println(i + " " + l);
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int q[] = new int[n];
        for (int i = 0; i < n; ++i) {
            q[i] = scan.nextInt();
        }
        for (int i = 0; i < m; ++i) {
            int k = scan.nextInt();
            find(q, k);
        }
    }
}
